package com.symone.webcms.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.symone.webcms.mapper.UserLogMapper;
import com.symone.webcms.model.UserLog;
import com.symone.webcms.service.UserLogService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author archerchu
 * @since 2018-11-18
 */
@Service
public class UserLogServiceImpl extends ServiceImpl<UserLogMapper, UserLog> implements UserLogService {

    @Override
    public Page<UserLog> findPage(Page<UserLog> page, Wrapper<UserLog> entity) {
        List<UserLog> result = baseMapper.selectPage(page,entity);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<String> getDistinctYmByCreateTime(String userName) {
        return baseMapper.getDistinctYmByCreateTime(userName);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean deleteFlagById(long id) {
        return baseMapper.deleteFlagById(id);
    }

    @Override
    public boolean deleteFlagByUid(long uid) {
        return baseMapper.deleteFlagByUid(uid);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<UserLog>().eq("deleted" ,1));
    }

    @Override
    public int deleteAll() {
        return baseMapper.delete(new EntityWrapper<UserLog>().where("1=1"));
    }
}
